<template>
  <div class="topic">
    <ul>
      <li v-for="item in dataArr" :key="item.id">
        <img v-lazy="item.scene_pic_url" alt="" />
        <h3>{{ item.title }}</h3>
        <p>{{ item.subtitle }}</p>
        <p class="p1">{{ item.price_info | text }}</p>
      </li>
    </ul>
    <van-pagination
      v-model="page"
      :page-count="pageCount"
      mode="simple"
      @change="changage"
    />
  </div>
</template>
<script>
// 引入专题页请求接口
import { getTopicData } from "@/utils/https";
export default {
  name: "Topic",
  data() {
    return {
      page: 1, //当前页数
      size: 10, //每页显示个数
      pageCount: 0, //总页数
      dataArr: [], //
    };
  },
  components: {},
  methods: {
    changage() {
      window.scrollTo(0,0)
      // window.scrollTo({top:0, behavior: "smooth"})//回到顶部
      this.getData();
    },
    getData() {
      getTopicData({
        page: this.page,
        size: this.size,
      }).then((res) => {
          console.log(res);
          var { data, currentPage, totalPages } = res.data.data;
          this.dataArr = data;
          this.page = currentPage;
          this.pageCount = totalPages;
        }).catch((err) => {});
    },
  },
  created() {
    this.getData();
  },
  mounted() {},
};
</script>
<style lang="less" scoped>
.topic {
  padding-bottom: 50px;
  ul {
    padding-bottom: 20px;
    li {
      height: 359px;
      padding-bottom: 20px;
      text-align: center;
      img {
        width: 100%;
        height: 208px;
      }
      h3 {
        height: 35px;
        padding: 8px 0;
        line-height: 35px;
        font-size: 18px;
      }
      p {
        padding: 10px 5px;
        height: 30px;
        line-height: 30px;
        font-size: 16px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
      .p1 {
        color: #8b0000;
      }
    }
  }
  /deep/.van-pagination__page-desc {
    display: none;
  }
}
</style>
